<template>
	<view class="">
		<MyTopNav></MyTopNav>
		<view class="bg-white padding-lr-lg " style="padding-bottom: 60rpx;">
			<el-row>
				<el-col :md="4" :sm="24">
					<MySideBar actvitiTag="user"></MySideBar>
					<MyRank></MyRank>
				</el-col>
				<el-col :span="20" class="padding-left-xl">
					<view v-for="(category, index) in categoryList" :key="index">
						<view class="tip">
							{{category.label}}
						</view>
						<el-row>
							<el-col :xl="4" :lg="6"  :sm="8" :xs="12" v-for="(subCateogry, subindex) in category.children" :key="subindex">
								<view class="sub-title margin">
									 <el-link @click="gotoSubCategory(subCateogry)">
										 <text class="sub-title">
											 {{subCateogry.label}}
										 </text>
									 </el-link>
								</view>
							</el-col>
						</el-row>
					</view>
				</el-col>
			</el-row>
		</view>
		<HomeNews></HomeNews>
		<MyFooter></MyFooter>
	</view>
</template>

<script>
	import {
		qbmsCategoryList
	} from '@/api/qbms.js';
	export default {
		data() {
			return {
				categoryList: [],
			}
		},
		
		onShow() {
			qbmsCategoryList().then(res => {
				this.categoryList = res.data;
			}).catch(err => {});
		},
		methods: {

			/**
			 * 跳转子分类
			 */
			gotoSubCategory(cateogry) {
				uni.navigateTo({
					url: "/pages/qbms/startPractice?categoryId="+cateogry.id + "&name="+ cateogry.label
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.tip {
		padding: 8px 16px;
		background-color: #E1F0FF;
		border-radius: 4px;
		border-left: 5px solid #3A77BA;
		margin: 20px 0;
		font-size: 20px;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #3A77BA;
		line-height: 24px;
	}

	.sub-title {

		height: 16px;
		font-size: 16px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		line-height: 16px;
	}
</style>
